package com.prj.ufdm.cloud.ms.auth.api;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import com.prj.ufdm.cloud.ms.core.model.PageBean;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import org.springframework.web.bind.annotation.RestController;
import com.prj.ufdm.cloud.base.dto.RetData;
import com.prj.ufdm.cloud.ms.auth.bpo.SysDutyBPO;
import com.prj.ufdm.cloud.ms.auth.model.SysDuty;


/**
 * <p>
 * 职务管理 前端控制器
 * </p>
 *
 * @author zhengzixiang
 * @since 2019-09-19
 */
@RestController
@RequestMapping("/api/auth/sysDuty")
public class SysDutyController {

 	@Autowired
    private SysDutyBPO sysDutyBPO;
    
    /**
   	 *查询列表
    */
    @RequestMapping("/doGetList")
	public RetData<PageInfo<SysDuty>> doGetList(PageBean pageBean,SysDuty t)  throws Exception {
		RetData<PageInfo<SysDuty>> retData = new RetData<PageInfo<SysDuty>>();
		PageHelper.startPage(pageBean.getPageNum(),pageBean.getPageSize());
		List<SysDuty>  list=sysDutyBPO.doGetList(t);
		PageInfo<SysDuty> page=new PageInfo<SysDuty>(list);
		retData.setRetBody(page);
		return retData;
	}
	 /**
   	 *通过id查询
    */
	@RequestMapping("/doGetById")
	public RetData<SysDuty> doGetById(String id)  throws Exception {
		RetData<SysDuty> retData = new RetData<SysDuty>();
		SysDuty result=sysDutyBPO.doGetById(id);
		retData.setRetBody(result);
		return retData;
	}
	/**
   	 *保存
    */
	@RequestMapping("/doSave")
	public RetData<String> doSave(@RequestBody SysDuty t)throws Exception{
		RetData<String> ret=new RetData<String>();
		sysDutyBPO.doSave(t);
		ret.setRetBody("");
		return ret;
	}
	
	/**
   	 *更新
    */
	@RequestMapping("/doModById")
	public RetData<String> doModById(@RequestBody SysDuty t)throws Exception{
		RetData<String> ret=new RetData<String>();
		sysDutyBPO.doModById(t);
		ret.setRetBody("");
		return ret;
	}
	
	/**
   	 *删除
    */
	@RequestMapping("/doRmById")
	public RetData<String> doRmById(String id)throws Exception{
		RetData<String> ret=new RetData<String>();
		SysDuty sysDuty =sysDutyBPO.doGetById(id);
		if(sysDuty!=null) {
			sysDutyBPO.doRmById(id);
		}
		ret.setRetBody("");
		return ret;
	}

}
